﻿#pragma once

#include "../Server/MirEnvir/Envir.h"
#include "../Server/MessageQueue.h"
#include "../Server/MirDatabase/CharacterInfo.h"
#include "../Server/MirEnvir/Timer.h"
#include "../Controls/FixedListViewControl/CustomFormControl.ListViewNF.h"
#include <string>
#include <vector>
#include <stdexcept>
#include <any>
#include "../stringhelper.h"

using namespace Server::MirEnvir;
using namespace Server::MirDatabase;
using namespace Server::MirForms::Systems;
using namespace Server::Database;


namespace Server
{
    class SMain : public System::Windows::Forms::Form
    {
    public:
        virtual ~SMain()
        {
            delete components;
            delete MainTabs;
            delete tabPage1;
            delete LogTextBox;
            delete StatusBar;
            delete PlayersLabel;
            delete MonsterLabel;
            delete ConnectionsLabel;
            delete MainMenu;
            delete controlToolStripMenuItem;
            delete startServerToolStripMenuItem;
            delete stopServerToolStripMenuItem;
            delete toolStripMenuItem1;
            delete closeServerToolStripMenuItem;
            delete InterfaceTimer;
            delete tabPage2;
            delete DebugLogTextBox;
            delete tabPage3;
            delete ChatLogTextBox;
            delete accountToolStripMenuItem;
            delete databaseFormsToolStripMenuItem;
            delete mapInfoToolStripMenuItem;
            delete itemInfoToolStripMenuItem;
            delete monsterInfoToolStripMenuItem;
            delete nPCInfoToolStripMenuItem;
            delete questInfoToolStripMenuItem;
            delete configToolStripMenuItem1;
            delete serverToolStripMenuItem;
            delete balanceToolStripMenuItem;
            delete systemToolStripMenuItem;
            delete dragonSystemToolStripMenuItem;
            delete guildsToolStripMenuItem;
            delete miningToolStripMenuItem;
            delete fishingToolStripMenuItem;
            delete tabPage4;
            delete groupBox1;
            delete GlobalMessageButton;
            delete GlobalMessageTextBox;
            delete PlayersOnlineListView;
            delete nameHeader;
            delete levelHeader;
            delete classHeader;
            delete genderHeader;
            delete indexHeader;
            delete mailToolStripMenuItem;
            delete goodsToolStripMenuItem;
            delete CycleDelayLabel;
            delete magicInfoToolStripMenuItem;
            delete refiningToolStripMenuItem;
            delete relationshipToolStripMenuItem;
            delete mentorToolStripMenuItem;
            delete gameshopToolStripMenuItem;
            delete gemToolStripMenuItem;
            delete conquestToolStripMenuItem;
            delete rebootServerToolStripMenuItem;
            delete respawnsToolStripMenuItem;
            delete monsterTunerToolStripMenuItem;
            delete reloadNPCsToolStripMenuItem;
            delete reloadDropsToolStripMenuItem;
            delete toolStripSeparator1;
            delete itemNEWToolStripMenuItem;
            delete monsterExperimentalToolStripMenuItem;
        }

        static Server::MirEnvir::Envir *getEnvir();

        static Server::MirEnvir::Envir *getEditEnvir();

    protected:
        static Server::MessageQueue *getMessageQueue();

    public:
        SMain();

    private:
        void AutoResize();

    public:
        static void Enqueue(std::runtime_error ex);

        static void EnqueueDebugging(const std::string &msg);

        static void EnqueueChat(const std::string &msg);

        static void Enqueue(const std::string &msg);

    private:
        void configToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void InterfaceTimer_Tick(std::any sender, EventArgs *e);

        ListViewItem *CreateListView(CharacterInfo *character);

        void ProcessPlayersOnlineTab();

        void startServerToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void stopServerToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void SMain_FormClosing(std::any sender, FormClosingEventArgs *e);

        void closeServerToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void itemInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void monsterInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void nPCInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void balanceConfigToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void questInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void serverToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void balanceToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void accountToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void mapInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void itemInfoToolStripMenuItem_Click_1(std::any sender, EventArgs *e);

        void monsterInfoToolStripMenuItem_Click_1(std::any sender, EventArgs *e);

        void nPCInfoToolStripMenuItem_Click_1(std::any sender, EventArgs *e);

        void questInfoToolStripMenuItem_Click_1(std::any sender, EventArgs *e);

        void dragonSystemToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void miningToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void guildsToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void fishingToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void GlobalMessageButton_Click(std::any sender, EventArgs *e);

        void PlayersOnlineListView_DoubleClick(std::any sender, EventArgs *e);

        void PlayersOnlineListView_ColumnWidthChanging(std::any sender, ColumnWidthChangingEventArgs *e);

        void mailToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void goodsToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void relationshipToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void refiningToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void mentorToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void magicInfoToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void SMain_Load(std::any sender, EventArgs *e);

        void gemToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void conquestToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void rebootServerToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void respawnsToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void monsterTunerToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void reloadNPCsToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void reloadDropsToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void gameshopToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void itemNEWToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void monsterExperimentalToolStripMenuItem_Click(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        TabControl *MainTabs;
        TabPage *tabPage1;
        TextBox *LogTextBox;
        StatusStrip *StatusBar;
        ToolStripStatusLabel *PlayersLabel;
        ToolStripStatusLabel *MonsterLabel;
        ToolStripStatusLabel *ConnectionsLabel;
        MenuStrip *MainMenu;
        ToolStripMenuItem *controlToolStripMenuItem;
        ToolStripMenuItem *startServerToolStripMenuItem;
        ToolStripMenuItem *stopServerToolStripMenuItem;
        ToolStripSeparator *toolStripMenuItem1;
        ToolStripMenuItem *closeServerToolStripMenuItem;
        Timer *InterfaceTimer;
        TabPage *tabPage2;
        TextBox *DebugLogTextBox;
        TabPage *tabPage3;
        TextBox *ChatLogTextBox;
        ToolStripMenuItem *accountToolStripMenuItem;
        ToolStripMenuItem *databaseFormsToolStripMenuItem;
        ToolStripMenuItem *mapInfoToolStripMenuItem;
        ToolStripMenuItem *itemInfoToolStripMenuItem;
        ToolStripMenuItem *monsterInfoToolStripMenuItem;
        ToolStripMenuItem *nPCInfoToolStripMenuItem;
        ToolStripMenuItem *questInfoToolStripMenuItem;
        ToolStripMenuItem *configToolStripMenuItem1;
        ToolStripMenuItem *serverToolStripMenuItem;
        ToolStripMenuItem *balanceToolStripMenuItem;
        ToolStripMenuItem *systemToolStripMenuItem;
        ToolStripMenuItem *dragonSystemToolStripMenuItem;
        ToolStripMenuItem *guildsToolStripMenuItem;
        ToolStripMenuItem *miningToolStripMenuItem;
        ToolStripMenuItem *fishingToolStripMenuItem;
        TabPage *tabPage4;
        GroupBox *groupBox1;
        Button *GlobalMessageButton;
        TextBox *GlobalMessageTextBox;
        CustomFormControl::ListViewNF *PlayersOnlineListView;
        ColumnHeader *nameHeader;
        ColumnHeader *levelHeader;
        ColumnHeader *classHeader;
        ColumnHeader *genderHeader;
        ColumnHeader *indexHeader;
        ToolStripMenuItem *mailToolStripMenuItem;
        ToolStripMenuItem *goodsToolStripMenuItem;
        ToolStripStatusLabel *CycleDelayLabel;
        ToolStripMenuItem *magicInfoToolStripMenuItem;
        ToolStripMenuItem *refiningToolStripMenuItem;
        ToolStripMenuItem *relationshipToolStripMenuItem;
        ToolStripMenuItem *mentorToolStripMenuItem;
        ToolStripMenuItem *gameshopToolStripMenuItem;
        ToolStripMenuItem *gemToolStripMenuItem;
        ToolStripMenuItem *conquestToolStripMenuItem;
        ToolStripMenuItem *rebootServerToolStripMenuItem;
        ToolStripMenuItem *respawnsToolStripMenuItem;
        ToolStripMenuItem *monsterTunerToolStripMenuItem;
        ToolStripMenuItem *reloadNPCsToolStripMenuItem;
        ToolStripMenuItem *reloadDropsToolStripMenuItem;
        ToolStripSeparator *toolStripSeparator1;
        ToolStripMenuItem *itemNEWToolStripMenuItem;
        ToolStripMenuItem *monsterExperimentalToolStripMenuItem;
    };
}
